@extends('newAdmin.layout.main')

@section('content')
    <div class="x-nav">
        <span class="layui-breadcrumb">
            <a href="">首页</a>
            <a href="">文章管理</a>
            <a><cite>文章主题</cite></a>
        </span>
        <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
            <i class="layui-icon" style="line-height:30px">ဂ 刷新</i>
        </a>
    </div>
    <div class="x-body">
        <div class="layui-row">
            <form id="add-theme" class="layui-form layui-col-md12 x-so layui-form-pane">
                {{csrf_field()}}
                <div class="layui-form">
                    <div class="layui-inline"><input class="layui-input" lay-verify="required" placeholder="主题名" name="name"></div>
                    <div class="layui-inline">
                        <select name="belong_to">
                            <option value="0">全部显示</option>
                            <option value="1">App</option>
                            <option value="2">PC</option>
                        </select>
                    </div>
                    <div class="layui-inline">
                        <input class="layui-btn" value="增加" lay-submit lay-filter="add" style="width:100%;" type="button">
                    </div>
                </div>
            </form>
        </div>
        {{--<xblock>--}}
            {{--<button class="layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon"></i>批量删除</button>--}}
            {{--<span class="x-right" style="line-height:40px">共有数据：88 条</span>--}}
        {{--</xblock>--}}
        <table class="layui-table">
            <thead>
            <tr>
                {{--<th>--}}
                    {{--<div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>--}}
                {{--</th>--}}
                <th>ID</th>
                <th>分类名</th>
                <th>显示客户端</th>
                <th>操作</th>
            </thead>
            <tbody>
            @foreach($list as $theme)
                <tr>
                    {{--<td>--}}
                        {{--<div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='2'><i class="layui-icon">&#xe605;</i></div>--}}
                    {{--</td>--}}
                    <td>{{$theme->id}}</td>
                    <td>{{$theme->name}}</td>
                    <td>{{$theme->belong_to_text}}</td>
                    <td class="td-manage">
                        <a title="编辑" onclick="x_admin_show('编辑', '{{url("backstage/editTheme", ['id' => $theme->id])}}')" href="javascript:;">
                            <i class="layui-icon font-24">&#xe642;</i>
                        </a>
                        {{--<a title="删除" onclick="member_del(this,'要删除的id')" href="javascript:;">--}}
                        {{--<i class="layui-icon">&#xe640;</i>--}}
                        {{--</a>--}}
                    </td>
                </tr>
            @endforeach
            </tbody>
        </table>
        <div class="page">
            {{$list->links()}}
        </div>
    </div>
    <script>
        $(function  () {
            layui.use('form', function(){
                const form = layui.form;
                //监听提交
                form.on('submit(add)', function(){
                    $.ajax({
                        url: '{{url("backstage/addTheme")}}',
                        type: 'POST',
                        dataType: 'json',
                        data: $('#add-theme').serialize(),
                        success: function (result) {
                            if (result.status === 0) {
                                layer.msg(result.msg);
                                location.href = '{{url("backstage/theme")}}';
                                return false;
                            }
                            layer.msg(result.msg);
                            return false;
                        },
                        error: function () {
                            layer.msg('增加失败，请重试！');
                            return false;
                        }
                    });
                    return false;
                });
            });
        })
    </script>
@endsection
